package commands;

import nanoxml.XMLElement;
import utils.ITransmittable;

/**
 * This command represents a request for the DB to check if
 * the name of the new user who wants to register to the game
 * already exists. 
 */
public class CommandCheckUserExists implements ITransmittable {
	
	private final static String ATTR_USER_NAME = "Username";
	
	private String username = null; 
	
	public CommandCheckUserExists (String username) {
		this.username = username;
	}
	public CommandCheckUserExists (XMLElement command) {
		this.username = (String) command.getAttribute(ATTR_USER_NAME);
	}
	
	@Override
	public XMLElement toXML() {
		XMLElement message  = new XMLElement();
		message.setName(Commands.CHECK_EXIST_USER);
		message.setAttribute(ATTR_USER_NAME, username);
		
		return message;
	}
	
	public String getUsername()
	{
		return username;
	}
}
